<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>登录</title>
    <link rel="stylesheet" href="css/bootstrap.min.css"/>
    <link rel="stylesheet" href="css/codecss.css"/>
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top" style="background-color: white;display: block;">
    <div class="container">
        <a href="#" class="left"><img src="img/codelogo.png" style="width: 50%;margin-top: 10px;margin-bottom: 10px;" ></a>
        <div class="navtext left">
            <a href="#">开发者平台</a>
        </div>
        <div class="navcode right">
            <a href="apiindex.html">开发者中心</a>
            <a href="APIlogin.html">应用管理</a>
            <a href="problem.html">常见问题</a>
            <a href="APIlogin.html">登录</a>
        </div>
    </div>
</nav>
<div  class="container codeview">
    <div class="col-md-9" style="margin: 0 auto;float: none;min-height: 730px;">
        <div id="c9tl"><span>登录</span></div>
        <div class="lin1" id="a0"></div>
        <div class="hd"></div>
<div style="margin: 30px auto;height: 360px;width: 660px;">
            <div class="logimg left">
                <img src="img/login_left_pic.png" style="width: 80%;">
            </div>
            <div class="rightLogin right">
                    <h3>欢迎登录</h3>
                    <form id="myForm">
                        <h6>账号</h6>
                        <input type="text" style="width: 280px;height: 30px" name="name"/>
                        <div style="height: 25px"><h6 style="float: left">密码</h6>
                        <p style="float: right;font-size: 14px;"><a href="" style="position: relative;top: 8px;right: 10px">忘记密码?</a></p></div>
                        <input type="text" style="width: 280px;height: 30px" name="pwd" id="pass"/>
                        <p style="font-size: 14px;"><a href="sub.html">还没有账号?赶快注册》</a></p>
                        <button type="button" class="btn btn-info" style="width: 280px;border-radius: 0px" id="sub" >登录</button>
                    </form>
                </div>

            </div>
    </div>

    </div>
</div>

<div class="foot2" style="position: absolute;bottom: 0px;">
    <div class="container">
        <div class="fta2 left" style="font-size: 14px;">
            <a href="#">关于平台</a>
            <a href="#">联系我们</a>
            <a href="#">开发者协议</a>
        </div>
        <span class="right" style="font-size: 14px;">Copyright © 2015 wisedu All Rights Reserved</span>
    </div>
</div>
</body>
<script type="text/javascript">
    document.getElementById("sub").addEventListener("click",function () {
        alert(1);
        var name = document.getElementById("name").value;
        var pass = document.getElementById("pass").value;
        if(name == "" || name == null) {
            alert("请输入手机号！");
            return;
        } else if(pass == "" || pass == null) {
            alert("请输入密码！");
            return;
        }  else{
            $.ajax('http://119.23.12.246:8080/index/app_login', {
                data: {
                    userName: name,
                    pwd: pass
                },
                dataType: 'json',
                type: 'post',
                timeout: 10000,
                success: function(data) {
                    if(data.code == 0000) {
                        window.location.href="loginIndex.html";
                        var name=$("#userName").val();
                        localStorage.setItem("name", name);
                        //localStorage.setItem("perId", data.result.date.perId);
                    } else {
                        alert("您的帐号或密码错误，请仔细核对后重新输入！")
                    }
                },
                error: function(xhr, type, errorThrown) {
                    console.log(type);
                    return;
                }
            });
        }

    })
</script>
</html>